package com.swu.cx.alwayslearning.annotation

import java.lang.reflect.ParameterizedType
import java.lang.reflect.Type

open class MyTypeToken<T> {
    var type: Type
        private set

    init {
        val genericSuperClz = javaClass.genericSuperclass
        val parameterizedType = genericSuperClz as ParameterizedType
        // 因为泛型可以有多个
        val actualTypeArgs = parameterizedType.actualTypeArguments
        type = actualTypeArgs[0]
    }

}